//
//  GradientBackgroundColorShadowButton.swift
//  SwiftUIButton
//
//  Created by 李煜 on 2024/7/30.
//

import SwiftUI

struct GradientBackgroundColorShadowButton: View {
    var body: some View {
        Button(action: {}, label: {
            Label(
                title: { Text("Label")
                    .fontWeight(.semibold)
                    .font(.title)
                },
                icon: { Image(systemName: "trash")
                    .font(.title)
                }
            )
            .padding()
            //添加线性渐进色背景
            .background(LinearGradient(colors: [.red,.blue], startPoint: .leading, endPoint: .trailing))
            .cornerRadius(40)
            .foregroundColor(.white)
        })
        
        //使用ColorSet方式创建颜色(16进制)
        Button(action: {}, label: {
            Label(
                title: { Text("Label")
                        .fontWeight(.semibold)
                        .font(.title)
                },
                icon: { Image(systemName: "trash")
                        .font(.title)
                }
            )
            .padding()
            //添加线性渐进色背景
            .background(LinearGradient(colors: [.darkGreen,.lightGreen], startPoint: .leading, endPoint: .trailing))
            .cornerRadius(40)
            .foregroundColor(.white)
//            .shadow(radius: 5)
            .shadow(color: .gray, radius: 20.0, x: 20, y: 10)
        })
        
    }
}

#Preview {
    GradientBackgroundColorShadowButton()
}
